<template>
  <div>
    <div class="f-r a-c">
      <div class="score-name">总分</div>
      <div class="score-num">
        {{ score }}
      </div>
    </div>
    <div class="search-params f-r a-c j-b">
      <el-form inline>
        <el-form-item label="筛选：">
          <el-date-picker
            v-model="searchParams.timeValue"
            type="datetimerange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" round @click="onSearch">筛选</el-button>
          <el-button round @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="table-box">
      <el-table
        v-loading="loading"
        height="400px"
        stripe
        :data="tableData"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
        @selection-change="onSelect"
      >
        <el-table-column type="index" width="80px" label="序号" align="center" />
        <el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
        <el-table-column label="分数变更">
          <template slot-scope="scope">
            <span style="color: #26B54C">+ {{ scope.row.score }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import crud from '@/mixins/crud'
import { http_performance } from '@/api'

export default {
  name: 'ScoreDetail',
  mixins: [crud],
  props: {
    userId: String,
    score: Number
  },
  data() {
    return {
      searchParams: {
        timeValue: []
      },
      options: {
        1: '重点项目约定完成领取土地证',
        2: '重点项目提前完成土地证',
        3: '一般项目约定完成土地证',
        4: '一般项目提前完成土地证',
        5: '重点项目约定竣工',
        6: '一般项目约定竣工',
        7: '没有约定时间完成'
      },
      columns: [
        { prop: 'projectName', label: '项目名称' },
        { prop: 'fractionTypeName', label: '项目权重' },
        { prop: 'arrangeTime', label: '领取施工许可证约定时间' },
        { prop: 'endTime', label: '领取施工许可证实际时间' }
      ]
    }
  },
  methods: {
    initData() {
      http_performance.scoreList({
        zdUserId: this.userId
      }).then(res => {
        this.tableData = res.data.map(el => {
          return {
            ...el,
            fractionTypeName: this.options[el.fractionType]
          }
        })
      })
    }
  }
}
</script>

<style scoped lang="scss">
.score-name {
  font-size: 36px;
  font-family: Microsoft YaHei-Regular, Microsoft YaHei;
  font-weight: 400;
  color: #333333;
}
.score-num {
  line-height: 95px;
  font-size: 72px;
  font-family: Microsoft YaHei-Regular, Microsoft YaHei;
  font-weight: 400;
  color: #FFA60C;
  margin-left: 41px;
}
</style>
